package com.sitanyun.merchant.guide.presenter.impl;

import com.sitanyun.merchant.guide.model.impl.LoginAModelImpl;
import com.sitanyun.merchant.guide.model.inter.ILoginAModel;
import com.sitanyun.merchant.guide.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.presenter.inter.ILoginAPresenter;
import com.sitanyun.merchant.guide.view.inter.ILoginAView;

public class LoginAPresenterImpl implements ILoginAPresenter {
    private ILoginAView mILoginAView;
    private ILoginAModel mILoginAModel;

    public LoginAPresenterImpl(ILoginAView aILoginAView) {
        mILoginAView = aILoginAView;
        mILoginAModel = new LoginAModelImpl();
    }

    @Override
    public void getLoginphone(String phone) {
        mILoginAModel.setLoginphone(phone, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mILoginAView.response(response,mILoginAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mILoginAView.response(t,mILoginAView.RESPONSE_TWO);
            }
        });
    }

    @Override
    public void getLogin(String phone, String password) {
        mILoginAModel.setLoginpass(phone, password, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mILoginAView.responselogin(response,mILoginAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mILoginAView.responselogin(t,mILoginAView.RESPONSE_TWO);
            }
        });
    }
}
